var JsonpPost = {
    request_id: 0,
    callbacks: [],
    scripts: [],
    proxy: null,
    setProxy: function(proxy){
        this.proxy = proxy;
    },
    callback: function(id,data){
        this.callbacks[id](data);
        document.body.removeChild(this.scripts[id]);
        delete this.callbacks[id];
        delete this.scripts[id];
    },
    get: function(page,data,callback){
        this.callbacks[++this.request_id] = callback;
        var script = document.createElement('script');
        var src = this.proxy + '?page=' + encodeURIComponent(page) + '&callback_id=';
        src += this.request_id.toString() + '&data=' + encodeURIComponent(JSON.stringify(data));
        script.setAttribute('type', 'text/javascript');
        script.setAttribute('src',src)
        this.scripts[this.request_id] = script;
        document.body.appendChild(script);
    }
};
